package gate_response

import (
	"proto/base"
)

type Option interface {
	Apply(*Options)
}

type Options struct {
	Code proto_base.ErrorCode
	Args []string
}

type funcOption struct {
	f func(*Options)
}

func WithErrorCode(code int) Option {
	return newFuncOption(func(opts *Options) {
		opts.Code = proto_base.ErrorCode(code)
	})
}

func WithErrorArgs(args []string) Option {
	return newFuncOption(func(opts *Options) {
		opts.Args = append(opts.Args, args...)
	})
}

func newFuncOption(f func(*Options)) *funcOption {
	return &funcOption{
		f: f,
	}
}

func (fo *funcOption) Apply(options *Options) {
	fo.f(options)
}
